<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
                <link rel="stylesheet" href="style.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
                
                 <script language="javascript">
                    function prompt(){
                        var question = confirm("Are you sure you want to delete this subject?");
                        if(question)
                           return true;
                        
                        else return false;
                           
                    }
                    
                </script>
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">VIEW SUBJECTS</a></li>
                                        <li><a href="view.php">BACK</a></li>
				
				</ul>
			</div>
			<div class="body">

<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
      include 'PHPClasses/DBAccess.php';
      include 'PHPClasses/Subject.php';
      include 'PHPClasses/SubjectDBAccess.php';
      include 'PHPClasses/TeacherDBAccess.php';
      




      
      $DBAccess=new SubjectDBAccess;
 
       echo "<table id=hor-minimalist-a>";
       echo "<thead><tr><th scope=col>Subject Name</th>
                  
      <th scope=col>Teacher In Charge</th></thead></tr>\n";
     
      
      
       $subjects=$DBAccess->viewDB();
    
       if(mysql_num_rows($subjects)==0){
                echo "<td scope=col>No Subjects Added!</td>";
       }

            while($subjectsRow = mysql_fetch_array($subjects))
            {
                extract($subjectsRow);
                
                $DBAccess=new TeacherDBAccess;
                $teacherRow=$DBAccess->getTeacherFromDB($idSubject);
                
                extract($teacherRow);
                
                echo "<tr>
                <td><a href='editSubject.php?subjectID=".$idSubject."' style='text-decoration:none; color:#636363;'>$subjectName</a></td>\n
                <td>$teacherName</td>\n
                
             
                <td>
                <form name='subjecttIDForm' action='deleteSubject.php' onsubmit='return prompt()' method='POST'>
                <input type='hidden'  name='subjectID' value='$idSubject'/><input class='addmore' type='submit' value='Delete Subject'/>       
                </form></td>";
            }
            
            echo "</tr></table>\n";
      
      $DBAccess->DBDisconnect(); 
?>
                         
                        </div>
                    
			<div class="footer">
				
				<p>&#169; Copyright &#169; 2011. Company name all rights reserved</p>
				<div class="connect">
					<a href=""><img src="images/paragox.png" width=160" height="110" alt=""/></a>
					<a href=""><img src="images/fblogo.png" width=120" height="100" alt="" style="position:relative; left:-31px"/></a>
					<a href=""><img src="images/harmony.png" width=120" height="100" alt="" style="position:relative; left:0px"/></a>
				</div>
			</div>
		</div>
	</body>
</html> 